package com.chen.gateway.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chen.common.GatewayResult;
import com.chen.common.utils.HttpClientUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.xml.crypto.Data;

/**
 * @decription:nginx服务器中状态
 * @author:chenhongwei
 * @create:2018-03-26-下午 7:05
 */
@Controller
@RequestMapping("statue")
public class StatueController {



    private String nginxServerUrl="http://123.206.201.120:9999/stat/status?";

    @RequestMapping("Statue")
    public String nginxStatue(Model model){
       String rspStr= HttpClientUtil.doGet(nginxServerUrl);
        JSONObject data =JSON.parseObject(rspStr);
        model.addAttribute("status",data);

       return "statue/status";
    }

    @RequestMapping("nginxstatue")
    @ResponseBody()
    public JSONObject statue(){
        String rspStr= HttpClientUtil.doGet(nginxServerUrl);
        JSONObject data =JSON.parseObject(rspStr);

        return data;
    }
}
